﻿using Basic.FlowCollect;
using Basic.FlowLocalEvent.Model;
using Basic.FlowRemoteModel;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowLocalEvent.FlowApp
{
    [LocalEventName("Delete")]
    internal class ClearAppForm : IEventHandler<FlowAppEvent>
    {
        private IFlowAppFormRelationCollect _Service;

        public ClearAppForm(IFlowAppFormRelationCollect service)
        {
            this._Service = service;
        }

        public void HandleEvent(FlowAppEvent data, string eventName)
        {
            if (data.App.AppType == FlowAppType.内部应用 && data.App.SettleFormId.HasValue)
            {
                _Service.Clear(data.App.Id);
            }
        }
    }
}
